//
//  StatusOriginalView.swift
//  weibo
//
//  Created by Fosen on 15/12/5.
//  Copyright © 2015年 fosen. All rights reserved.
//

import UIKit
import SDWebImage
class StatusOriginalView: UIView {

    //添加类型属性
    var status:Status? {
    
    didSet{
    
        headImageView.sd_setImageWithURL(status?.user?.headImageURL, placeholderImage: UIImage(named: "avatar_default_big"))
        nameLabel.text = status?.user?.name
        mbrankImage.image = status?.user?.mbrankImage
        avatar_type_image.image = status?.user?.verified_type_name
//        timeLabel.text = status?.created_at
//        sourceLabel.text = status?.source
        contentLabel.text = status?.text
    }
    
    
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
        backgroundColor = UIColor(white: 0.95, alpha: 1)
    }

    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    //设置UI
    private func setupUI(){
    
        addSubview(headImageView)
        addSubview(nameLabel)
        addSubview(mbrankImage)
        addSubview(avatar_type_image)
        addSubview(timeLabel)
        addSubview(sourceLabel)
        addSubview(pictureView)
        addSubview(contentLabel)
        
        
        headImageView.snp_makeConstraints { (make) -> Void in
            
            make.top.left.equalTo(self.snp_top).offset(StatusCellMargin)
            make.size.equalTo(CGSize(width: StatusCellImageWidth, height: StatusCellImageWidth))

        }
        nameLabel.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top).offset(StatusCellMargin)
            make.left.equalTo(headImageView.snp_right).offset(StatusCellMargin)
            
        }
        mbrankImage.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top).offset(StatusCellMargin)
            make.left.equalTo(nameLabel.snp_right).offset(StatusCellMargin)
            
        }
        avatar_type_image.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(headImageView.snp_right)
            make.centerY.equalTo(headImageView.snp_bottom)

        }
        timeLabel.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(headImageView.snp_bottom)
            make.left.equalTo(headImageView.snp_right).offset(StatusCellMargin)
            
        }
        
        sourceLabel.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(headImageView.snp_bottom)
            make.left.equalTo(timeLabel.snp_right).offset(StatusCellMargin)
            
        }
        contentLabel.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(headImageView.snp_bottom).offset(StatusCellMargin)
            make.left.equalTo(self.snp_left).offset(StatusCellMargin)
            
        }
        
        pictureView.snp_makeConstraints { (make) -> Void in
            
            make.top.equalTo(contentLabel.snp_bottom).offset(StatusCellMargin)
            make.left.equalTo(contentLabel.snp_left)
            make.size.equalTo(CGSize(width: 100, height: 100))
            
        }
        
        self.snp_makeConstraints { (make) -> Void in
            
            make.bottom.equalTo(pictureView.snp_bottom).offset(StatusCellMargin)
        }
        
        
    }

    
    //懒加载子控件
    private lazy var headImageView:UIImageView = UIImageView()
    
    private lazy var nameLabel :UILabel = UILabel(title: "fosenfosen", color: labelColor, fontSize: 14)
    private lazy var avatar_type_image :UIImageView = UIImageView(image: UIImage(named: "avatar_vip"))
    private lazy var mbrankImage :UIImageView = UIImageView(image: UIImage(named: "common_icon_membership_level6"))
    private lazy var timeLabel :UILabel = UILabel(title: "22:22", color: labelColor, fontSize: 10)
    private lazy var sourceLabel :UILabel = UILabel(title: "iPhone6s Plus", color: labelColor, fontSize: 10)
    
    private lazy var contentLabel :UILabel = UILabel(title: "测试文字：萨芬的家乐福哈酒缩放后撒谎放假哈士大夫阿斯蒂芬大师傅大放送氨基酸地方哈绝色赌妃回家啊看来房价还未日晚", color: labelColor, fontSize: 10,margin: StatusCellMargin)
    private lazy var pictureView: StatusPictureView = StatusPictureView()

}
